Skip to content
This repository was archived by the owner on Aug 28, 2026. It is now read-only.

Apply API key middleware to /v2/check and /v2/authorize - #75

Closed
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
feature/sec-1235-fga-edge-agent-serves-the-environments-entire-authorization
Closed

Apply API key middleware to /v2/check and /v2/authorize#75
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
feature/sec-1235-fga-edge-agent-serves-the-environments-entire-authorization

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

The data-plane routes /v2/check and /v2/authorize were served with only loggingMiddleware. This change applies the existing API key middleware (ServerConfig.ApiKey) to these routes so they require a configured key, consistent with other endpoints.

Please review before merging.

The edge agent served /v2/check and /v2/authorize behind only logging
middleware, so any actor with network access to the agent could query
the cached authorization graph without credentials. ServerConfig.ApiKey
was populated but never enforced on inbound requests.

Add authMiddleware that validates the Authorization header against the
configured API key (constant-time compare), matching the cloud API's
"Authorization: ApiKey <key>" scheme, and reject unauthenticated
requests with 401 before the handler runs. Fail closed when no key is
configured. /health stays unauthenticated for readiness probes.

Add HTTP-level regression tests covering unauthenticated, wrong-key,
and valid-key requests.
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author
Original prompt from Linear User

Please work on ticket "FGA Edge Agent serves the environment's entire authorization graph over unauthenticated /v2/check and /v2/authorize endpoints (API key accepted in config but never enforced)" (SEC-1235)

@playbook:playbook-b588614117c7477a9b9729928385384f

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@linear-code

linear-code Bot commented Jul 22, 2026

Copy link
Copy Markdown

SEC-1235

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds API-key authentication to the edge agent's data-plane endpoints. The main changes are:

  • Requires Authorization: ApiKey <key> on /v2/check and /v2/authorize.
  • Rejects data-plane requests when no API key is configured.
  • Leaves /health available without authentication.
  • Extracts mux construction into Server.Handler().
  • Adds HTTP tests for accepted and rejected credentials.

Confidence Score: 5/5

This looks safe to merge.

  • Both data-plane routes use the new authentication middleware.
  • Missing configuration and invalid credentials fail closed.
  • The health route remains available for readiness checks.
  • No blocking issues were found in the changed code.

Important Files Changed

Filename Overview
errors.go Adds the standardized unauthorized error returned for failed authentication.
middleware.go Adds constant-time API-key authentication before protected handlers run.
server.go Protects both data-plane routes and extracts mux construction for reuse in tests.
server_test.go Adds HTTP coverage for missing, incorrect, and valid credentials and the open health route.

Reviews (1): Last reviewed commit: "Require API key auth on /v2/check and /v..." | Re-trigger Greptile

@devin-ai-integration
devin-ai-integration Bot deleted the feature/sec-1235-fga-edge-agent-serves-the-environments-entire-authorization branch July 27, 2026 16:15
@devin-ai-integration devin-ai-integration Bot changed the title Require API key auth on /v2/check and /v2/authorize Apply API key middleware to /v2/check and /v2/authorize Jul 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

0 participants